package CS4310.csueb.visual;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

public class ExperienceBar extends JPanel
{
	private JLabel attribute;
	private JProgressBar status;
	private JButton decrease;
	private JButton increase;
	
	
	public ExperienceBar(String att, int amt)
	{
		attribute = new JLabel(att);
		
		status = new JProgressBar();
		status.setValue(amt);
		
		decrease = new JButton("-");
		decrease.setActionCommand(att+"-");
		decrease.setPreferredSize(new Dimension(50, 20));
		
		increase = new JButton("+");
		increase.setActionCommand(att+"+");
		increase.setPreferredSize(new Dimension(50, 20));
		
		this.setPreferredSize(new Dimension(300, 50));
		this.setLayout(new FlowLayout(FlowLayout.LEFT));
		this.add(attribute);
		this.add(status);
		this.add(decrease);
		this.add(increase);
	}
	
	public ExperienceBar(String att, int amt, boolean btn)
	{
		this(att, amt);
		if(!btn)
		{
			this.remove(decrease);
			this.remove(increase);
		}
	}
	
	public void addActionListener(ActionListener arg0)
	{
		decrease.addActionListener(arg0);
		increase.addActionListener(arg0);
	}
	
	public void enable(boolean b)
	{
		decrease.setEnabled(b);
		increase.setEnabled(b);
	}
	
	public void update(int value)
	{
		status.setValue(value);
	}
}
